#!/bin/bash
#author: ycs

# all="app auth data file gateway listener marketing notification pay search settlement system third"
lzmh_services="app auth data file gateway listener notification pay search settlement system"
wxzy_services="marketing third"

start(){
  for i in $lzmh_services; do
    if [[ -d /opt/application/$i ]]; then
      PID=$(ps -ef | grep $i.jar | grep -v grep | awk '{ print $2 }')
      if [[ -z $PID ]] ; then
	 cd /opt/application/$i
         nohup java -Xms512m -Xmx1024m -jar lzmh-$i.jar > out.log 2>&1 &
         echo "$i service startup"
      else
        echo "$i service already startup"
       fi
    fi
  done
}

start_wxzy(){
  for i in $wxzy_services; do
    if [[ -d /opt/application/$i ]]; then
      PID=$(ps -ef | grep $i.jar | grep -v grep | awk '{ print $2 }')
      if [[ -z $PID ]] ; then
	 cd /opt/application/$i
         nohup java -Xms512m -Xmx1024m -jar wxzy-$i.jar > out.log 2>&1 &
	 echo "$i service startup"
      else
        echo "$i service already startup"
      fi
    fi
  done
}

start
start_wxzy

echo "service all startup"
